from technology.models import Technology, Use, Know


def technology_view(technology):
    assert isinstance(technology, Technology)
    view = {
        'id': technology.id,
        'name': technology.name,
        'detail': technology.detail,
        'users': [{
            'id': know.uid.id,
            'name': know.uid.name
        } for know in Know.objects.filter(tid=technology).order_by('uid_id')],
        'projects': [{
            'id': use.pid.id,
            'name': use.pid.name
        } for use in Use.objects.filter(tid=technology).order_by('pid_id')]
    }
    return view
